<template>
	<view style="padding: 30px;">
		<button @click="onSetTimeOut()" type="primary">单次计时器</button>
		<button @click="onSetTimeOut('kjw', 'aaa')">启动传参计时器</button>
		<button @click="onClearTimeOut()" type="warn">取消计时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:"zhengsan",
				timer1:null
			}
		},
		methods: {
			onSetTimeOut() {
				console.log("onSetTimeOut()");
				
				this.timer1 = setTimeout(()=>{
					console.log("onSetTimeOut() callback");
					console.log("onSetTimeOut() callback end");
				},3000);
			},
			
			onClearTimeOut(){
				console.error("onSetTimeOut() 取消计时器")
				clearTimeout(this.timer1);
			}
		}
	}
</script>

<style>
	button {
		margin: 20px;
	}
</style>